home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 401-425 / disk_408 / post / post13.lzh / Post / post.doc < prev    next >
Text File  |  1990-10-27  |  21KB  |  610 lines

  1. Postscript interpreter - user documentation
  2. ===========================================
  3.  
  4. Post V1.3 Copyright Adrian Aylward 1989, 1990
  5.  
  6. Free use and non-commercial reproduction of the binaries of the interpreter
  7. library (post.library) is permitted, providing that the copyright notices
  8. are not removed.  Distribution by disk libraries is permitted provided only
  9. a nominal copying fee is charged.
  10.  
  11. You may freely copy, use and modify the user interface program (post).  The
  12. source is included in the distribution.
  13.  
  14. All other rights are reserved.  For queries and bug reports write to the
  15. author:
  16.  
  17.         Adrian Aylward,
  18.         20 Maidstone Road,
  19.         SWINDON,
  20.         Wiltshire.
  21.         UK.
  22.  
  23. No responsibilities accepted for bugs, but please let me know so I can fix
  24. them.
  25.  
  26. Introduction
  27. ============
  28.  
  29. "Post" is a software based PostScript interpreter, presently running on the
  30. Amiga.  The source code is written in C, and should be fairly portable to
  31. other machines.  It supports the full Adobe language, with only minor
  32. variations.
  33.  
  34. Prerequisites
  35. =============
  36.  
  37. Post uses the Arp library (V39+), primarily for its file requestor.  For
  38. interactive working you also need ConMan (V1.3+).  Both these programs are
  39. widely available; any good BBS or PD/shareware library should have them.
  40. (ConMan is shareware.)  You may well have them installed on your machine
  41. already.
  42.  
  43. If you prefer not to install ConMan as your standard console handler, you
  44. will need to access it via an alternative device name, which you must
  45. specify by the CONDEV option.
  46.  
  47. You will need at least a megabyte of memory, more for high density printer
  48. output.
  49.  
  50. Command line interface
  51. ======================
  52.  
  53. usage:
  54.     post [files...] [IFF file] [SCREEN] [PRINTER] [INTERACTIVE]
  55.          [SIZE xyod..s..p.bc.] [MEM fhlv..] [CLOSEWB] [CONDEV con]
  56.  
  57. If you forget, type "post ?" to display this.
  58.  
  59. The input files
  60. ---------------
  61.  
  62. The interpreter reads the input files in turn.  When running interactively
  63. the input files are treated as startup files, and are rerun whenever the
  64. interpreter is restarted.  So you would normally specify just the standard
  65. startup file "init.ps", or an alternative of you own.  When running
  66. non-interactively you should in addition specify all the files you want to
  67. interpret, up to 5 in total; when the last is finished the interpreter will
  68. exit.
  69.  
  70. Printer output
  71. --------------
  72.  
  73. This is the default if neither the IFF nor SCREEN options are used, when
  74. running non-interactively.  The output is sent to the printer device as a
  75. graphic dump.
  76.  
  77. The interpreter will obtain default values for the page size, density, and
  78. number of colors from the current preferences.  If you use the default sizes
  79. make sure you have set the page size: run preferences and on the graphic 2
  80. screen set the width and height limits -  either bounded or absolute or in
  81. pixels.  The output defaults to black and white or 3 colour, according to
  82. the preferences.
  83.  
  84. IFF file output
  85. ---------------
  86.  
  87. This option will send the output to an IFF file.  Each IFF file contains a
  88. single FORM ILBM.  So that multiple pages may be created in a single run of
  89. the interpreter, sequence numbers are automatically generated:
  90.  
  91.     IFF path/fred*.pic   will generate  path/fred1.pic, path/fred2.pic ...
  92. and IFF path/fred??.pic  will generate  path/fred01.pic, path/fred02.pic ...
  93.  
  94. The default page size etc. is the same as for screen output.
  95.  
  96. SCREEN output
  97. -------------
  98.  
  99. This option  will send the output to a window on the interactive screen.  It
  100. implies interactive working.
  101.  
  102. You can generate screen, printer and IFF output at the same time.  But since
  103. screen output has to use chip memory and printer output at high resolution
  104. needs a large page buffer (about a megabyte for an A4 page at 300 dpi.) you
  105. will probably run out of memory if you attempt the two simultaneously.
  106.  
  107. The default screen size is the same as the workbench screen, but in
  108. interlace mode.  The default page size is A4, with a density of 75 pixels
  109. per inch.  The default number of colours is 3.  The page size is rounded up
  110. to the maximum size of the window.
  111.  
  112. The INTERACTIVE option
  113. ----------------------
  114.  
  115. This option causes the interpreter to run interactively.  A screen is opened
  116. and on it appears a requestor window for the parameters.  If you click on
  117. OK two windows will be opened, one for console input and output, and the
  118. other to display the page buffer.  Use the menus.
  119.  
  120. The SIZE option
  121. ---------------
  122.  
  123. The SIZE option sets the page size and density etc..
  124.  
  125.     SIZE "x..y..s..xo..yo..[x]d..[y]d..p.bc."
  126.  
  127. Up to 5 SIZE options are allowed; later values override earlier ones.
  128.  
  129. The page sizes ("x..y..s..") are in pixels, as decimal numbers; "s" sets
  130. the size of the bands, for band rendering to the printer.  The page offsets
  131. are in pixels, shifting the location of the bottom left of the bitmap
  132. relative to the PostScript logical page (origin at (0,0) in the initial user
  133. space). Densities ([x]d..[y]d..) are in pixels per inch; "xd" or "yd" set
  134. the x or y density, and "d" sets both.
  135.  
  136. The printer density can be set by "p"; its value should be in the range 
  137. 1 to 7.
  138.  
  139. The number of colours is: "b" for black and white (1 bit plane), "c" or "c3"
  140. for 3 colour rgb (3 bit planes), and "c4" for 4 colour cmyk (4 bit planes).
  141.  
  142. The MEM option
  143. --------------
  144.  
  145. The MEM option controls the amount of memory allocated for workspace.
  146.  
  147.     MEM "v..f..l..h.."
  148.  
  149. Up to 5 MEM options are allowed; later values override earlier ones.
  150.  
  151. The memory defaults are chosen to suit a large machine processing relatively
  152. complex pages.  For simple screen output much lower minimums are possible -
  153. if you don't have enough memory on your machine try the small values
  154. instead.
  155.  
  156.     Default   Small
  157.     -------   -----
  158.     v600000  (80000)     Virtual machine memory
  159.      f60000   (1000)     Font cache
  160.      l60000   (8000)     Line drawing and image workspace
  161.      h20000   (1000)     Halftone buffer
  162.  
  163.      (x+64) * (y+16) / 8 Page buffer
  164.  
  165. The default values should run on a 1.5MB machine with output to the screen
  166. On a 2MB machine it should be possible to generate a complex A4 page of
  167. printer output at 300 dpi.
  168.  
  169. The CLOSEWB option
  170. ------------------
  171.  
  172. If memory is tight, you can try using this option to close down WorkBench
  173. while Post is running.  This only works if there are no application
  174. windows open on the WorkBench screen.
  175.  
  176. The CONDEV option
  177. -----------------
  178.  
  179. If you do not have ConMan installed as the default console handler, you
  180. must use this option to specify its device name (without the ":").
  181.  
  182. Examples
  183. --------
  184.  
  185. To run postscript programs interactively, rendering to the screen:
  186.  
  187.     post init.ps screen
  188.  
  189. To print a file with many big characters using a large font cache and
  190. increasing the path limit:
  191.  
  192.     post init.ps myfile.ps printer mem f500000l200000
  193.  
  194. To render a series of 640 * 512 pictures at 762 dpi. to iff files t:i01,
  195. t:i02 etc.:
  196.  
  197.     post init.ps mypics.ps iff t:i?? size x640y512d72
  198.  
  199. The WorkBench interface
  200. =======================
  201.  
  202. Just click on the icon.  It always runs interactively.  You can set up
  203. default arguments by setting the ToolTypes; add a string "ARGS=...."
  204. and it will be parsed just like the CLI startup.  For example
  205. "ARGS=init.ps screen" will define the standard startup file and make the
  206. screen the default output.
  207.  
  208. The Menus
  209. =========
  210.  
  211. Project
  212.     Restart              Takes you back to the parameters requestor, after
  213.                          which the interpreter is reinitialised.
  214.  
  215.     Quit                 Quit from the program
  216.  
  217. File
  218.     Load font            Loads a file from the PSFonts: directory by default
  219.  
  220.     Load file            Loads a file, without saving or restoring the VM
  221.  
  222.     Run file             Runs a file, saving VM before and restoring after
  223.  
  224.     Interactive          Interprets interactive input
  225.  
  226. Control
  227.     Pause every page     Toggles pause every showpage/copypage
  228.  
  229.     Continue after pause Does just that
  230.  
  231.     Interrupt            Sends a break; equivalent to CTRL/C
  232.  
  233. Before and after executing a file the operand stack is cleared.  This is
  234. to prevent invalidrestore errors, particularly if interpretation ended in
  235. error with values on the stack.  If you need to leave things on the stack
  236. you will have to run the files from a driver file, or from the interactive
  237. window.  At the end of the file, (after any restore), the page is erased.
  238.  
  239. If you use the automatic font loading, as defined in the standard startup
  240. file "init.ps", the font will be discarded when the VM is restored.  To
  241. avoid repeated reloading of common fonts it may be better to use the "Load
  242. font" menu item to preload the ones you want.  N.B. there is no check to
  243. stop you loading the same one twice; it will probably work but it will
  244. waste memory.
  245.  
  246. Compatability
  247. =============
  248.  
  249. The interpreter is based upon the language (version "23.0") as described by
  250. the (red) book:
  251.  
  252.     "PostScript Language Reference Manual"
  253.     Adobe Systems Incorporated,
  254.     Addison-Wesley 1985, ISBN 0-201-10174-2
  255.  
  256. The 4 colour operators are also supported as described by the document:
  257.  
  258.     "PostScript Language Color Extensions"
  259.     Adobe Systems Incorporated (23-Jan-90)
  260.  
  261. File handling
  262. -------------
  263.  
  264. The files %stdin, %stdout, %stderr are permanently open as far as the
  265. operating system is concerned.  Attempts to close them will invalidate the
  266. file object but not close them to the operating system.  If they are
  267. connected to a terminal they will be unbuffered, so output will be
  268. transmitted immediately, without waiting for a "flush".  The special files
  269. %statementedit and %lineedit are not supported.  There is no end of file
  270. control character.
  271.  
  272. Error handling
  273. --------------
  274.  
  275. A new error "invalidstop" has been added.
  276.  
  277. The execution stack
  278. -------------------
  279.  
  280. The exact contents of the execution stack are not defined by the language
  281. reference manual, and cannot therefore be guaranteed to be the same as other
  282. implementations.  Dumping the stack is likely to yield useful debugging
  283. information but is not recommended for normal programming.
  284.  
  285. Colour mapping
  286. --------------
  287.  
  288. The interpreter can run with one bit plane (for black and white printers),
  289. 3 bit planes (red, green, blue) or 4 bit planes (cyan, magenta, yellow,
  290. black).  For screen output 3 bit planes are appropiate.  For a colour
  291. printer the 3 or 4 colour model can be used.  The output is always in
  292. binary; gray scale is supported only via the halftone mechanism.
  293.  
  294. For low resolution colour printers the 3 colour model is probably best.
  295. The 4 color model is for high resolution colour printers that can generate
  296. high frequency halftone screens, where a fourth screen is used to improve
  297. the quality of the blacks and grays.
  298.  
  299. (N.B. the preferences printer drivers only handle 3 colour model, so if
  300. you want to use the 4 colour model you will probably need to generate an
  301. IFF file and write your own print dump program.  They will however
  302. automatically use black the ribbon/ink if the printer has one)
  303.  
  304. The transformations between the RGB and the HSB models are based on those in
  305. the book:
  306.  
  307.     "Procedural Elements for Computer Graphics"
  308.     David F. Rogers,
  309.     McGraw-Hill 1985, ISBN 0-E07-053534-5.
  310.  
  311. Band Rendering
  312. --------------
  313.  
  314. For a high resolution printer the page buffer can be quite large (a megabyte
  315. or so).  If you don't have enough memory to hold the entire page at once you
  316. can render each one in several bands.  Set the "SIZE s..." option to the
  317. largest band size you have space for.  (For matrix printers it will probably
  318. be best to make it a multiple of the number of printer pins times the number
  319. of vertically displaced passes).  Then run the postscript program generating
  320. each page once for each band, using the "setband" operator, which is
  321. described below, to set the base for each band.  Start at a base of zero
  322. and increment the base by the band size until you reach the page height.
  323. Each band is sent to the printer as a separate graphic dump; the last band
  324. generates a form feed to eject the page.  You can use the "currentband"
  325. operator to calculate the number of bands needed:
  326.  
  327.     currentband 1 sub { setband pageproc } for 0 setband
  328.  
  329. will execute "pageproc" once for each band (remaining) on the page.  The
  330. procedure should execute copypage (or showpage) exactly once per iteration.
  331.  
  332. N.B. this technique is only suitable for printer output.
  333.  
  334. Fonts
  335. -----
  336.  
  337. There are no fonts built in to the interpreter; they must all be downloaded.
  338. The findfont operator will execute the error invalidfont if the font you
  339. request is not present in the font dictionary.  You can redefine it, perhaps
  340. to search the Unix/Amiga filing system to automatically download fonts or to
  341. substitute a default font.  See the standard startup file.
  342.  
  343. Both type 1 (Adobe encrypted format) and type 3 (standard PostScript as per
  344. the red book) fonts are now supported.  In addition the IBM font format can
  345. be read directly.
  346.  
  347. The font caching will work significantly better if all your fonts have
  348. UniqueID's.  Then repeated makes of the same font with the same matrix will
  349. be cached, and cached character bitmaps can be retained even if the font
  350. is removed by a restore operation.  N.B. if fonts are downloaded after a
  351. save they will be removed by the corresponding restore; in the interests of
  352. efficiency it may therefore be better to preload them.
  353.  
  354. Other features
  355. --------------
  356.  
  357. Names of the form //name are looked up immediately by the scanner, and
  358. packed arrays have been implemented.  These features were not on the
  359. original Adobe red book, but were added to the language specification later.
  360.  
  361. When scanning the contents of a string, if there any embedded strings the
  362. escape sequences are interpreted just as they are in a file.  This follows
  363. the specification of the more recent Adobe interpreters (including display
  364. PostScript) and not the original red book.
  365.  
  366. Operators omitted or changed
  367. ----------------------------
  368.  
  369.     banddevice
  370.  
  371. Not appropiate for the Unix/Amiga environment.
  372.  
  373.     bytesavailable
  374.  
  375. Since we can't tell how many bytes are available we always return -1.
  376.  
  377.     copypage
  378.  
  379. For printer output this works like the standard.  The number of pages
  380. printed is equal to #copies.  For screen output it does not need to do
  381. anything, as the screen is not buffered.  For IFF file output it writes the
  382. page to the next file.
  383.  
  384.     echo
  385.  
  386. Not appropiate for the Unix/Amiga environment.
  387.  
  388.     eexec
  389.  
  390. This is implemented as per the Adobe type 1 fonts book.  Its operand must be
  391. a file, which must match the object on top of the execution stack.  It can be
  392. terminated only by a closefile (which terminates the eexec but does not
  393. actually close the file).  So the sequences "currentfile eexec" and
  394. "currentfile closefile" as described in the book will work, but other
  395. combinations will likely fail.
  396.  
  397.     executive
  398.  
  399. There is no executive, as the interpreter supports interactive usage
  400. directly.
  401.  
  402.     findfont
  403.  
  404. Looks in the FontDirectory.  If it can't find the supplied key, it executes
  405. the error invalidfont.
  406.  
  407.     flushfile
  408.  
  409. We don't check for errors when flushing an input file, to prevent recursion
  410. in the error handler.
  411.  
  412.     framedevice
  413.  
  414. Not appropiate for the Unix/Amiga environment.
  415.  
  416.     prompt
  417.  
  418. Not called by the interpreter.  See "prompts" instead.
  419.  
  420.     renderbands
  421.  
  422. Not appropiate for the Unix/Amiga environment.
  423.  
  424.     resetfile
  425.  
  426. Does nothing.
  427.  
  428.     showpage
  429.  
  430. See the notes for copypage above.
  431.  
  432.     usertime
  433.  
  434. Returns the time elapsed since the interpreter started, with a resolution of
  435. one second.
  436.  
  437. Operators added
  438. ---------------
  439.  
  440.     currentband
  441.  
  442.         "currentband" base size height
  443.  
  444. Returns the base of the current band, size of each band, and total height
  445. of the page.
  446.  
  447.     setband
  448.  
  449.         base "setband"
  450.  
  451. Sets the base height of the band being rendered.  The value must be greater
  452. than or equal to zero and less than the total height of the page.
  453.  
  454.     fontfile
  455.  
  456.         (filename) "fontfile"
  457.  
  458. Opens a file for reading.  If the first byte is hex "80" the file is assumed
  459. to be in IBM font format, and its contents are converted to standard
  460. ascii/binary as they are read.  The standard input file (%stdin) is never in
  461. IBM font format.
  462.  
  463.     invalidstop
  464.  
  465.         (error)
  466.  
  467. A "stop" has been executed for which there is no dynamically enclosing
  468. "stopped" context.
  469.  
  470.     prompts
  471.  
  472.         string string "prompts"
  473.  
  474. The first string is used as the prompt when the interpreter is scanning
  475. terminal input and executing it immediately; the second string is used when
  476. execution is defered while scanning the contents of a procedure "{ ... }".
  477. No prompt is given when a newline is encountered within a string.
  478.  
  479.     vmhwm
  480.  
  481.         "vmhwm" hwmused maximum
  482.  
  483. Returns two integers: the high water mark of the amount virtual memory used
  484. since the program was first started or the last "vmhwm", and the maximum
  485. available amount of memory.
  486.  
  487. Miscellaneous
  488. -------------
  489.  
  490. The system dictionary is left writeable so that standard preludes can add
  491. things to it - possibly removing write permission when they have finished.
  492. Similarly FontDirectory is writeable, so that it is possible to add entries
  493. without using definefont.
  494.  
  495. Device space
  496. ------------
  497.  
  498. The largest device that the interpreter can handle is 31767 (sic) by 32767
  499. pixels.  In practice you will probably run out of memory long before
  500. reaching this limit.
  501.  
  502. Known Bugs
  503. ==========
  504.  
  505. If you close down WorkBench the menus sometimes get truncated and slightly
  506. corrupted.  I suspect this is a Workbench/Intuition problem.
  507.  
  508. If you type CTRL/C to abort if the printer is not ready then strange things
  509. may happen on subsequent attempts to print.
  510.  
  511. N.B. if you run very low on memory, Intuition may behave strangely, and
  512. refuse to resize windows etc..  This is not a bug in Post.
  513.  
  514. If you type CTRL/backslash in the interactive window you won't be able to
  515. run interactively again until a restart.
  516.  
  517. Post tries to keep the console window active, so that all keyboard input
  518. goes there.  It will probably be incompatible with mouse handlers that
  519. automatically activate the window under the cursor.
  520.  
  521. Versions
  522. ========
  523.  
  524.     V0.0  14-Nov-89 (prerelease)
  525.  
  526. The original.
  527.  
  528.     V0.1  06-Dec-89 (prerelease)
  529.  
  530. Image routines added.
  531.  
  532. Range checks eased on gray levels and colours etc..
  533.  
  534. Area filling speeded up, matrix manipulation and colour mapping rewritten,
  535. numeric conditioning improved for path fill.
  536.  
  537. Bugs fixed: syntax error, == string escapes, error handling and quit when
  538. recursing, vm error handling, integer overflow in path fill, matrix save,
  539. interrupt after printing page, dictionary second save, name table restore,
  540. boolean type checking, multiple halftone screens memory allocation.
  541.  
  542.     V0.2  07-Jan-90 (prerelease)
  543.  
  544. Font and character routines added.  Null device added.  Band rendering of
  545. printer output added.
  546.  
  547. Matrix manipulation rewritten again.  Interpreter recursion rewritten.
  548. Allocate stacks dynamically.
  549.  
  550. Bugs fixed: missing access checks on strings, scan token negative chars,
  551. depth check in path flattening, pathbbox, strings or null objects as
  552. dictionary keys, shade after grestore(all), fill/image with clip region,
  553. clip unclosed subpath, dictstack/execstack.
  554.  
  555.     V1.0  12-Feb-90
  556.  
  557. Support for big scrollable windows added.  Menu handler added with port
  558. name option.  Workbench startup added with parameters requestor window.
  559.  
  560. Hex string scan optimised.  Break now CTRL/C only, not CTRL/D.
  561.  
  562. Bugs fixed: aspect ratio in iff file, clipping pictures much wider than the
  563. page.
  564.  
  565.     V1.1  27-Mar-90
  566.  
  567. Interpreter made into shared library.  Message port interface removed.
  568. Band printing driver now included.
  569.  
  570. Immediate lookup of //name added.  Packed arrays added.  CR and CRLF now
  571. converted to LF for readline and when scaning tokens from a file.  Copypage
  572. now takes account of #copies. 
  573.  
  574. Bugs fixed: slow images where strings are not rectangles, attributes after
  575. copy and bind, charpath with fonts using gsave, iff run compression,
  576. setundercolorremoval now conforms to Adobe spec, make errorname literal,
  577. slow images repositioned by 1/2 pixel.
  578.  
  579.     V1.2  14-Oct-90
  580.  
  581. Allow multiple SIZE and MEM options.
  582.  
  583. Page offset option added, page size defaults to A4, integer gadgets checked
  584. for +ve values.
  585.  
  586. Type 1 fonts, IBM font format, encrypted files, eexec operator added.
  587.  
  588. Bugs fixed: location zero not zero, printer device signals, proc arrays not
  589. executable, bind packed arrays, restore closing files, makefont matrices not
  590. commutative, makefont with translation, error handling during recursion,
  591. graphics state within buildchar proc, miterlimit less that sqrt(2), cvs
  592. copying too many bytes, solid lines after dashes, floating point error trap
  593. recursion (2620 version on 68882), check for fpu present, charpath with null
  594. character path, error handling loading file, invalid restore check,
  595. writehexstring.
  596.  
  597.     V1.3  27-Oct-90
  598.  
  599. LaserJet driver added.
  600.  
  601. Interface fixes: Menus no longer ghost after startup file error and restart,
  602. pause status is now retained over a restart, printer preferences page size
  603. is now handled correctly, no longer crashes if arp.library is missing.
  604.  
  605. Bugs fixed: IBM binary eexec sections beginning with white space, funny
  606. characters in error message command names, hints with stems of negative
  607. width, font character cache sizing, tune baseline alignment and flex,
  608. eexec lines ending in CR (not CRLF), aload packed arrays, zero length
  609. charstrings, font character cache hash chains.
  610.